<template>
  <div>
    <section class="main">
      <input
        id="toggle-all"
        class="toggle-all"
        type="checkbox"
        @click="isshowAll"
      />
      <label for="toggle-all">Mark all as complete</label>
      <ul class="todo-list">
        <!-- 当任务已完成，可以给 li 加上 completed 类，会让元素加上删除线 -->
        <li
          class="{completed:item.completed}"
          v-for="item in list"
          :key="item.id"
        >
          <div class="view">
            <input
              class="toggle"
              type="checkbox"
              checked
              v-model="item.completed"
              
            />
            <label>{{ item.text }}</label>
            <button class="destroy" @click="clearList(item.id)"></button>
          </div>
        </li>
        <!-- <li>
          <div class="view">
            <input class="toggle" type="checkbox" :checked="clearList" />
            <label>{{ item.text }}</label>
            <button class="destroy"></button>
          </div>
        </li> -->
      </ul>
    </section>
  </div>
</template>

<script>
export default {
  props: {
    list: {
      type: Array,
      required: true
    },
    checkAll: {
      type: Boolean,
      required: true
    }
  },
  components: {},
  data () {
    return {}
  },
  methods: {
    clearList (id) {
      this.$emit('clearList', id)
    },
    isshowAll () {
      this.$emit('isshowAll', this.checkAll)
    },
    // change (id) {
    //   this.$emit('isshowAll', id)
    // }
  }
}
</script>

<style scoped lang="less"></style>
